// @ts-nocheck
import { CONNECTED, Master } from "message-lite";
import "./hack";
import { TimerService } from "./services/define";
import { globalTimer } from "./timer";

export function atServer(server: Master) {
    server.on(CONNECTED, async () => {
        const [session] = server.getSession()
        await globalTimer.setSleepFn((time) => {
            const service = session.getService(TimerService);
            return service.timeout(time);
        });
        await session.closed.finally(() => {
            globalTimer.setSleepFn(null);
        });
    });
}